package wodegua.d23_test;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 需求:
 * 某护士小花，作息规律为上二天班，休息一天，经常不确定休息日是否是周末(注:首次休息日是2022年2月3日)。
 * 具体功能点的要求如下
 * 1、请你开发一个程序，当小花输入年以及月后，立即显示出该月份的休息日详情。
 * 示范(注意:示范信息重点在于参考格式，结果不一定是准确的，请自行确保计算结果正确性):
 * 请小花输入查询的月份(月份必须是2022年2月之后的月份):2023-5。
 * 2023-5-1[休息〕2023-5-2 2023-5-3 2023-5-4[休息]
 * 2、显示出该月份哪些休息日是周六或周日(请依次列出具体的日期和其星期信息)。
 * 3、小花给自己设置了一个高考倒计时。高考的开始时间为:2023年06月07日上午9:00。请利用给的素材代码(在Timer文件夹下)，补全代码，产生一个如下的倒计时效果，倒计时格式如下图所示:
 *
 */
public class Test03 {
    private static LocalDate startDate = LocalDate.of(2022,2,3);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入查询年月，需在2022-02之后，例：2022-03");
        String inDate = scanner.next();
        LocalDate endFirstDate = LocalDate.parse(inDate + "-01");
        LocalDate endLastDate = endFirstDate.plusMonths(1).minusDays(1);
        System.out.println("输入年月=" + endFirstDate + "-" + endLastDate);
        System.out.println("-----------------------");

        List<Day> days = new ArrayList<>();
        while (!startDate.isAfter(endLastDate)) {
            Day day = new Day(startDate, false, null);
            day.setWeek(startDate.getDayOfWeek().toString());
            days.add(day);
            startDate = startDate.plusDays(1);
        }
        for (int i = 0; i < days.size(); i+=3) {
            days.get(i).setFlag(true);
        }
        System.out.println("所有日期=" + days);
        System.out.println("-----------------------");

        for (int i = 0; i < days.size(); i++) {
            Day day = days.get(i);
            if (day.getDay().isBefore(endFirstDate)) {
                continue;
            }
            System.out.println(day.getDay() + (day.getFlag() ? "[休息]" : "") + (day.getFlag() && (day.getWeek().equals("SUNDAY") || day.getWeek().equals("SATURDAY")) ? "[" + day.getWeek() + "]" : ""));
        }
//        List<Day> daysMonth = days.stream().filter(s->!s.getDay().isBefore(endFirstDate) && s.getFlag())
//                .collect(Collectors.toList());
//        System.out.println(daysMonth);

    }
}

class Day{
    private LocalDate day;
    private boolean flag;
    private String week;

    public Day() {
    }

    public Day(LocalDate day, boolean flag, String week) {
        this.day = day;
        this.flag = flag;
        this.week = week;
    }

    @Override
    public String toString() {
        return "{day=" + day +
                ", flag=" + flag +
                ", week='" + week + "}";
    }

    public LocalDate getDay() {
        return day;
    }

    public void setDay(LocalDate day) {
        this.day = day;
    }

    public boolean getFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getWeek() {
        return week;
    }

    public void setWeek(String week) {
        this.week = week;
    }
}